/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pope.table;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author zxw
 */
public class MusicTableModel extends AbstractTableModel{
    private List<MusicModel> values;
    
    public MusicTableModel() {
        values = new ArrayList<MusicModel>();
    }

    public int getRowCount() {
        return values.size();
    }

    public int getColumnCount() {
        return MusicModel.TITLES.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        MusicModel mm = values.get(rowIndex);
        return mm.getColumnValue(columnIndex);
    }

    @Override
    public String getColumnName(int column) {
        return MusicModel.TITLES[column];
    }
    
    // -----------------------------------------------------------
    
    public List<MusicModel> getValues() {
        return values;
    }
    
    public synchronized void addValue(MusicModel music) {
        values.add(music);
    }
    
    public synchronized void clear() {
        values.clear();
    }
}
